let $main = $('.main');
let tttt
let id
let init = {
  url: 'http://chst.vip:1234/api/getbrandtitle',
  success: e
}
function e(res) {
  let str = ''
  res.result.forEach(element => {
    str += `   
    <li id=${element.brandTitleId}>
      <span>${element.brandTitle}</span>
      <svg class="icon" aria-hidden="true">
        <use xlink:href="#icon-sanjiao1"></use>
      </svg>
      <div class="container clear">
      </div>
    </li>
  `
  });
  $main.html(str)
}

function s(res) {
  let str = ''
  let a = 0
  res.result.forEach(element => {
    a++;
    str += `
      
      <a href="./priceparity.html?title=${tttt}&categoryid=${id}" class="tag" id="${element.brandId}">
      <i>${a}</i>
      <em>${element.brandName}</em>
      <span>${element.brandInfo}</span>
      </a>`
  });
  let arr = []
  arr.push(str)
  let $container = $('.container');
  $container.html(arr[0])
  str = ''
}
ajaxAPI(init)
$main.on('click', 'li', function (e) {
  $(this).find('.container').stop().slideToggle(300)
  $(this).siblings().find('.container').stop().slideUp(300)
  // console.log($(this).siblings().find('.container'));
  // e.preventDefault()
  id = $(this).attr('id')
  let data = {
    url: 'http://chst.vip:1234/api/getbrand?brandtitleid=' + id,
    success: s
  }
  ajaxAPI(data)
  let tttt = 1;
  let $tag = $(this).children('.container').children('.tag');

  $tag.on('click',function(){
    let id = $(this).attr('id');
    console.log(id);
  })
})


